package cn.melonlib.record.oper.comp.config;

import cn.melonlib.cores.aop.anno.PrependUrl;
import cn.melonlib.record.oper.anno.OperatorRecordService;
import cn.melonlib.record.oper.comp.interceptor.OperatorRecordInterceptor;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

import javax.annotation.Resource;

@Configuration
@DependsOn({"operatorRecordInterceptor"})
public class OperationRecordAopConfig {

    @Resource
    private OperatorRecordInterceptor operatorRecordInterceptor;

    @Bean
    public DefaultPointcutAdvisor operatorRecord(){
        AnnotationMatchingPointcut pointcut=new AnnotationMatchingPointcut(OperatorRecordService.class,true);
        DefaultPointcutAdvisor defaultPointcutAdvisor=new DefaultPointcutAdvisor();
        defaultPointcutAdvisor.setPointcut(pointcut);
        defaultPointcutAdvisor.setAdvice(operatorRecordInterceptor);
        defaultPointcutAdvisor.setOrder(99999);
        return defaultPointcutAdvisor;
    }


}
